<?php

include("../service/ProductService.php");

function buildProductBoxForHomePage($product, $langs) {
    $proImage = mysql_fetch_array(getImageOfProduct($product['PRO_ID']));

    echo ("<div class='product_box_home'>");
    echo ("<a href='product-detail.php?id=" . $product['PRO_ID'] . "'>");
    if ($proImage['IMG_PATH'] != "") {
        echo ("<img src='../images/product/PRO_" . $product['PRO_ID'] . "/" . $proImage['IMG_PATH'] . "' width='180' height='180' />");
    } else {
        echo "<img src='../images/cat/noimg.jpg' width='180' height='180' />";
    }
    
    $title = $product['PRO_NAME_' . $_SESSION["lang"]] . ' ' . $product['PRO_CODE'];
    
    if (strlen($title) > 25 ) {
        $title = substr($title, 0, 24) . "...";
    }
    
    echo ("</a>");
    echo ("<div class='text_box'>");
    echo ("<table cellpadding='0' cellspacing='0'>");
    echo ("<tr>");
    echo ("<td colspan='2'>");
    echo ("<strong>" . $title . "</strong>");
    echo ("</td>");
    echo ("</tr>");
    echo ("<tr>");
    echo("<td class='price_home'>");
    echo($langs['home.price'] . ": " . number_format($product['PRO_PRICE'], 0, ",", ".") . "<sup> VND</sup>");
    echo("</td>");
    echo("<td>");
    echo ("<a href='product-detail.php?id=" . $product['PRO_ID'] . "' class='button tiny right'>" . $langs['home.detail'] . "</a>");
    echo("</td>");
    echo ("</tr>");
    echo ("</table>");
    echo ("</div>");
    echo ("</div>");
}

function buildProductBox($product, $langs) {
    $proImage = mysql_fetch_array(getImageOfProduct($product['PRO_ID']));

    echo ("<div class='product_box'>");
    echo ("<a href='product-detail.php?id=" . $product['PRO_ID'] . "'>");
    if ($proImage['IMG_PATH'] != "") {
        echo ("<img src='../images/product/PRO_" . $product['PRO_ID'] . "/" . $proImage['IMG_PATH'] . "' width='180' height='180' />");
    } else {
        echo "<img src='../images/cat/noimg.jpg' width='180' height='180' />";
    }
    echo ("</a>");
    echo ("<div class='text_box'>");
    echo ("<span>" . $product['PRO_NAME_' . $_SESSION["lang"]] . ' ' . $product['PRO_CODE'] . "</span></br> <span>" . $langs['home.price'] . ": " . number_format($product['PRO_PRICE'], 0, ",", ".") . " VND</span>");
    echo ("</div>");
    echo ("<div class='button_group'>");
    echo ("<a href='product-detail.php?id=" . $product['PRO_ID'] . "' class='button left'>" . $langs['home.detail'] . "</a> <a onclick='addToCart(" . $product['PRO_ID'] . ", 1)' class='button left'>" . $langs['home.order'] . "</a>");
    echo ("</div>");
    echo ("</div>");
}